package com.ruoyi.match.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.match.domain.MatchClass;
import com.ruoyi.match.service.IMatchEquipmentService;

import com.ruoyi.match.domain.MatchEquipment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author å®è¿å
 * @date 2021-03-07
 */
@Api(tags = "equipment")
@RestController
@RequestMapping("/match/equipment")
public class MatchEquipmentController extends BaseController
{
    @Autowired
    private IMatchEquipmentService matchEquipmentService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="pageNum" , value = "开始页码",required = false, defaultValue = "1",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name ="pageSize" , value = "每页显示的条目数",required = false,defaultValue = "10",dataType = "int",paramType = "query"),

    })
    public TableDataInfo list( )
    {
        startPage();
        List<MatchEquipment> list = matchEquipmentService.selectMatchEquipmentList(null);
        return getDataTable(list);
    }


    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation("根据id查询")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(matchEquipmentService.selectMatchEquipmentById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation("新增设备")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("add")
    @ApiImplicitParam(name = "matchEquipment", value = "设备号",dataType = "String",paramType = "body")
    public AjaxResult add(@RequestBody MatchEquipment matchEquipment)
    {
        matchEquipment.setId(IdUtils.randomUUID());
        return toAjax(matchEquipmentService.insertMatchEquipment(matchEquipment));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation("修改设备")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiImplicitParam(name = "matchEquipment", value = "",dataType = "MatchEquipment",paramType = "body")
    public AjaxResult edit(@RequestBody MatchEquipment matchEquipment)
    {
        return toAjax(matchEquipmentService.updateMatchEquipment(matchEquipment));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation("批量删除设备")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiImplicitParam(name = "ids", value = "ids",dataType = "Integer",paramType = "path",allowMultiple = true)
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(matchEquipmentService.deleteMatchEquipmentByIds(ids));
    }

//
    @ApiOperation(" 获取用户在线设备列表")
    @GetMapping("/online/{id}")
    public AjaxResult online(@PathVariable String ids){
        return null;
    }
}
